using FriendStar.Code;
using FriendStar.Domain.Entity.BaseData;
using FriendStar.Domain.IRepository.BaseData;
using FriendStar.Repository.BaseData;
using System.Collections.Generic;
using System.Linq;
using SqlSugarRepository;

namespace FriendStar.Application.BaseData
{
    public class CPK_61_PC_StoCPKAIAOAccoApp
    {
        private ICPK_61_PC_StoCPKAIAOAccoRepository service = new CPK_61_PC_StoCPKAIAOAccoRepository();

        public List<CPK_61_PC_StoCPKAIAOAccoEntity> GetList()
        {
            return service.IQueryable().ToList();
        }
        public CPK_61_PC_StoCPKAIAOAccoEntity GetForm(string keyValue)
        {
            return service.FindEntity(keyValue);
        }

        public CPK_61_PC_StoCPKAIAOAccoEntity GetStoCPKAIAOAccoForOutStock(string productionNO,string proCompanyNO,string productionTypeNO,string storeNO)
        {
            string useUnit = Configs.GetValue("UseUnit");
            return service.FindEntity(p => p.UseUnit == useUnit&&p.FProductionNO==productionNO&&p.FProductionTypeNO==productionTypeNO&&p.FStoreNO ==storeNO &&p.FQuantity_RK-p.FQuantity_CK>0);
        }
        public void DeleteForm(string keyValue)
        {
            
        }
        public void SubmitForm(CPK_61_PC_StoCPKAIAOAccoEntity CPK_61_PC_StoCPKAIAOAccoEntity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                service.Update(CPK_61_PC_StoCPKAIAOAccoEntity);
            }
            else
            {
                service.Insert(CPK_61_PC_StoCPKAIAOAccoEntity);
            }
        }
    }
}
